package com.bum.game.web.controller;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;

import com.bum.game.bo.Game;
import com.google.appengine.api.datastore.Entity;

public class GamesManageController extends ParameterizableViewController {
	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = super.handleRequestInternal(request, response);

		Iterable<Entity> games = Game.getAll();
		
		List<Map<String, Object>> list = new LinkedList<Map<String,Object>>();
		for (Entity game : games) {
			list.add(game.getProperties());
		}
		mv.addObject("games", list);

		return mv;
	}
}
